package hn.cch.fallback;

import feign.hystrix.FallbackFactory;
import hn.cch.entity.Product;
import hn.cch.entity.User;
import hn.cch.service.ProductService;
import hn.cch.service.UserService;
import org.springframework.stereotype.Component;

@Component
public class UserFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public User getOne(Integer id) {
                //显示异常
                throwable.printStackTrace();
                //容错
                User user = new User();
                user.setUserId(-1);
                return user;
            }
        };
    }
}
